package br.com.verde.exemploteca.functions

object FunctionsV4 {
  // Improvemnts with Currying
  
  def sum(f: Int => Int): (Int, Int) => Int = {
    def sumFunction(a: Int, b: Int): Int =
      if (a > b) 0 else f(a) + sumFunction(a + 1, b)
    sumFunction
  }
  
  def sumInts = sum(x => x)
  
  def sumSquares = sum(x => x * x)
  
  def main(args : Array[String]) : Unit = {
    println("Ei")
    println(sumSquares(1, 3))
  }
}
